package com.sharemarking.system.mapper;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.sharemarking.system.entity.Permission;
import com.sharemarking.system.service.impl.MybatisCacheFactoryEhcacheImpl;

@CacheNamespace(implementation=MybatisCacheFactoryEhcacheImpl.class)
public interface PermissionMapper {
	@Select("SELECT * FROM sys_permission")
	List<Permission> getAll();
	@Select("SELECT id FROM sys_permission WHERE domain=#{domain} AND name=#{name}")
	Integer getIdByDomainAndName(@Param("domain")String domain,@Param("name")String name);
	@Insert("INSERT INTO sys_permission(domain,name,description) "
			+ "VALUES(#{domain},#{name},#{description})")
	void insert(Permission permission);
	@Update("UPDATE sys_permission "
			+ "SET domain=#{domain},name=#{name},description=#{description} "
			+ "WHERE id=#{id}")
	void updateInfo(Permission permission);
	@Delete("DELETE FROM sys_permission WHERE domain=#{domain}")
	void deleteByDomain(String domain);
}
